package com.kdgz.kdgz.controller;

import com.kdgz.kdgz.beans.Salarys;
import com.kdgz.kdgz.mapper.SalaryMapper;
import com.kdgz.kdgz.sevice.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author Veneno
 * @Desc
 * @date 2021/4/7
 */
@RestController
public class SalaryController {

    @Autowired
    SalaryService salaryService;

    /**
     * 获得某个员工所有的工资信息
     * @param sid 员工id
     * @return java.util.List<com.kdgz.kdgz.beans.Salarys>
     */
    @GetMapping("/salarys/{sid}")
    public List<Salarys> getSalarysBySid(@PathVariable("sid") Integer sid){
        return salaryService.list(sid);
    }

    /**
     * 获得某个员工的某年所有工资
     * @param sid 员工id
     * @param year 年份
     * @return java.math.BigDecimal
     */
    @GetMapping("/salarys/{sid}/{year}")
    public BigDecimal getAllSalaryBySidYear(@PathVariable("sid") Integer sid,@PathVariable("year") Integer year){
        return salaryService.listByYear(sid,year);
    }
}
